import {readdir} from "fs/promises";
import Span from "@/app/course/Span";

type Props = { params: {}, searchParams: { c: string } }
// 学科页面, 显示已有题库
export default async function CoursePage(props: Props) {
    const dir = await readdir(`public/questions/${props.searchParams.c}`)

    return (
        <div className={'flex flex-col items-center gap-4 p-4'}>
            {dir.map((d, i) => (
                <div key={i} className={'flex w-3/4 justify-between rounded-lg shadow-md bg-green-50'}>
                    <Span c={props.searchParams.c} q={d}>
                        {d}
                    </Span>
                </div>
            ))}
        </div>
    )
}